Remove successive 0th entries in args[] for a Java command line interface?

Posted by Bill IV on Stack Overflow See other posts from Stack Overflow or by Bill IV
Published on 2010-06-16T20:24:23Z Indexed on 2010/06/16 20:32 UTC
Read the original article Hit count: 186

Filed under:
|
|
|
|

I recall seeing, somewhere, an example that stepped through String args[] by deleting the lowest numbered value(s)

public static void main( String args[]) {
    while (args.length > 0 ) {
    // do something and obliterate elements from args[]
    }
}

Obviously, a variable tracking current position in args and compared to args.length will do it; or an ArrayList made from args[]'s contents, with argsAL.size(). Am I mis-remembering an ArrayList example? I know this is a borderline question, the likely answer is, "No, there isn't and there shouldn't be either!". Maybe I'm over-focused...

Bill

© Stack Overflow or respective owner

Related posts about java

Related posts about array